/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package helloword;



import java.text.MessageFormat;
import java.io.File;
import net.jxta.platform.NetworkManager;

/**
 * A example of strating and stopping JXTA
 */
public class HelloWorld {

    /**
     * Main method
     *
     * @param args none defined
     */
    public static void main(String args[]) {
        NetworkManager manager = null;

        try {
            manager = new NetworkManager(NetworkManager.ConfigMode.ADHOC, "HelloWorld", new File(new File(".cache"), "HelloWorld").toURI());
            System.out.println("Starting JXTA");
            manager.startNetwork();
            System.out.println("JXTA Started");
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
        System.out.println("Waiting for a rendezvous connection");
        boolean connected = manager.waitForRendezvousConnection(12000);

        System.out.println(MessageFormat.format("Connected :{0}", connected));
        System.out.println("Stopping JXTA");
        manager.stopNetwork();
    }
}


